﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace blackhouse.BlackApart.Business {
    public class ExceptionAparts : Exception {

        public int Code { get; private set; }
        public Dictionary<string, object> AddData { get; private set; }

        public ExceptionAparts(int errorCode, Exception innerException)
            : base(GetMessage(errorCode), innerException) {
            this.Code = errorCode;
            this.AddData = new Dictionary<string, object>(0);
        }

        public ExceptionAparts(int errorCode, Exception innerException, params KeyValuePair<string, object>[] addData)
            : base(GetMessage(errorCode), innerException) {
            this.Code = errorCode;
            this.AddData = new Dictionary<string, object>(addData.Length);
            for (int xad = 0; xad < addData.Length; xad++) {
                this.AddData.Add(addData[xad].Key, addData[xad].Value);
            }
        }

        private static string GetMessage(int code) {
            return string.Format("Application terminated unexpectedly error number: {0}", code);
        }

    }
}
